﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimpleFactory
{
    class Program
    {
        static void Main(string[] args)
        {
            LightSimpleFactory lsf = new LightSimpleFactory();

            Light l = lsf.Create("Bulb");
            l.TurnOn();
            l.TurnOff();

            Console.WriteLine("-----------------");

            l = lsf.Create("Tube");
            l.TurnOn();
            l.TurnOff();

            Console.ReadKey();
        }
    }



    public abstract class Light
    {
        public abstract void TurnOn();
        public abstract void TurnOff();
    }


    public class BulbLight : Light
    {

        public override void TurnOn()
        {
            Console.WriteLine("Bubl Turn On ");
        }

        public override void TurnOff()
        {
            Console.WriteLine("Bubl Turn Off ");
        }
    }


    public class TubeLight : Light
    {

        public override void TurnOn()
        {
            Console.WriteLine("Tube Turn On ");
        }

        public override void TurnOff()
        {
            Console.WriteLine("Tube Turn Off ");
        }
    }


    public class LightSimpleFactory
    {
        public Light Create(string LightType)
        {
            if (LightType == "Bulb")
                return new BulbLight();
            else if (LightType == "Tube")
                return new TubeLight();
            else
                return null;
        }
    }
}
